package core

import (
	"commons/handler/request"
	"commons/handler/response"
	"commons/record"
	"imi/config"
	"imi/middle"
	"net/http"
)

func Run(w http.ResponseWriter, r *http.Request) {
	response.Response = w
	request.Request = r
	w.Header().Set("Access-Control-Allow-Origin", "*")             //允许访问所有域
	w.Header().Add("Access-Control-Allow-Headers", "Content-Type") //header的类型
	w.Header().Set("content-type", "application/json")
	record.LogInfo("《《《《《《《《《 " + r.URL.Path)
	fun := config.GetRouter(r.RequestURI)
	if fun == nil {
		fun = config.GetRouter("/error")
	}

	middle.Register(fun)
}
